package com.itboye.mengwu.data.presenter;

import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.core.object.BasePresenter;
import com.itboye.core.object.ResultEntity;
import com.itboye.mengwu.app.ui.main.MainPresenter;
import com.itboye.mengwu.data.interfaces.ILogGIns;
import com.itboye.mengwu.data.repository.LoginRepository;

import java.util.List;
import java.util.Observer;

/**
 * Created by itboye on 2017/4/18.
 */

public class LogGinPresenter extends BasePresenter implements ILogGIns<String> {

    //自动登录
    public static final String AddGoods_success = MainPresenter.class.getName()
            + "_AddGoods_success";
    public static final String AddGoods_fail = MainPresenter.class.getName()
            + "_AddGoods_fail";
    public LogGinPresenter(Observer observer) {
        super(observer);
        // TODO Auto-generated constructor stub
    }
    @Override
    public void OnLogin(String uid, String login_session) {
        ILogGIns<String> addGoods = new LoginRepository(
                new ICompleteListener() {

                    @Override
                    public void success(ResultEntity result) {
                        // TODO Auto-generated method stub
                        result.setEventTag(Tag_Success);
                        result.setEventType(AddGoods_success);
                        LogGinPresenter.this.setChanged();
                        LogGinPresenter.this.notifyObservers(result);
                    }

                    @Override
                    public void failure(ResultEntity result) {
                        // TODO Auto-generated method stub
                        result.setEventTag(Tag_Success);
                        result.setEventType(AddGoods_fail);
                        LogGinPresenter.this.setChanged();
                        LogGinPresenter.this.notifyObservers(result);

                    }
                });
        addGoods.OnLogin(uid,login_session);//("", "", "", "");
    }

    @Override
    public void add(String model) {

    }

    @Override
    public void delete(String model) {

    }

    @Override
    public void update(String model) {

    }

    @Override
    public void getInfo(String model) {

    }

    @Override
    public List<String> queryYouHuiQuan(String model) {
        return null;
    }
}
